package com.t4.courseware.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.t4.courseware.common.Result;
import com.t4.courseware.mapper.CarouselMapper;
import com.t4.courseware.pojo.Carousel;
import com.t4.courseware.service.CarouselService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class CarouselServiceImpl extends ServiceImpl<CarouselMapper, Carousel> implements CarouselService {

    @Resource
    private CarouselMapper carouselMapper;

    @Override
    public Result listCarouse() {
        LambdaQueryWrapper<Carousel> queryWrapper = Wrappers.<Carousel>lambdaQuery().gt(Carousel::getIsCarousel, 0).orderByAsc(Carousel::getIsCarousel);
        queryWrapper.select(Carousel::getId,Carousel::getCarouselUrl);
        List<Carousel> carouselList = carouselMapper.selectList(queryWrapper);
        return Result.SUCCESS(carouselList);
    }
}
